﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMK.Framework.Model;
using XMK.Tadong.Data;
using XMK.Tadong.Model;
using XMK.Utils;
using XMK.Tadong.Model.Cond;
using System.Data;
namespace XMK.Tadong.Biz
{
    /// <summary>
    /// 个人共享文档业务类
    /// </summary>
 public class Tb_Person_File_ShareBiz
    {
        public Tb_Person_File_ShareBiz()
        { 
        }
        /// <summary>
        /// 共享文档
        /// </summary>
        /// <param name="fileObj"></param>
        /// <returns></returns>
        public bool Share(TB_PERSON_FILE_SHAREInfo fileShareObj)
        {
            bool result = false;
            Tb_Person_File_ShareData fileData = new Tb_Person_File_ShareData(Config.TadongDbProvider);
            if (!fileData.IsExist(fileShareObj))
            {
                result = fileData.InsertNewFile(fileShareObj);
            }
            return result;
        }

     /// <summary>
        /// 根据课题组ID获得当前课题组共享文件
     /// </summary>
     /// <param name="teamId"></param>
     /// <returns></returns>
        public DataTable getShareFileInfoByTeamName(string teamId, string sorttype, string sortdesc, int startNum, int endNum, ref int total)
        {
             DataTable binddt = new DataTable();
             Tb_Person_File_ShareData fileData = new Tb_Person_File_ShareData(Config.TadongDbProvider);
             binddt = fileData.getShareFileInfoByTeamId(teamId, sorttype, sortdesc,startNum, endNum, ref total);
             return binddt;

            //获取提交者名称
 
        }

        /// <summary>
        /// 获得项目库共享文件
        /// </summary>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public DataTable getXmkShareFileInfo(int startNum, string sorttype, string sortdesc, int endNum, ref int total)
        {
            DataTable binddt = new DataTable();
            Tb_Person_File_ShareData fileData = new Tb_Person_File_ShareData(Config.TadongDbProvider);
            binddt = fileData.getXmkShareFileInfo(startNum,sorttype,sortdesc, endNum, ref total);
            return binddt;

            //获取提交者名称

        }
        // <summary>
        /// 获得当前用户所有共享文件
        /// </summary>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public DataTable getShareFileInfoByUserId(string userId, string sorttype, string sortdesc, int startNum, int endNum, ref int total)
        {

            Tb_Person_File_ShareData data = new Tb_Person_File_ShareData(Config.TadongDbProvider);
            return data.getShareFileInfoByUserId(userId, sorttype, sortdesc, startNum, endNum, ref total);
        }
        /// <summary>
        /// 删除当前用户选中共享文件
        /// </summary>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public bool deleteShareFileInfoByFileId(string fileId,string OBJ_ID)
        {

            Tb_Person_File_ShareData data = new Tb_Person_File_ShareData(Config.TadongDbProvider);
            return data.deleteShareFileInfoByFileId(fileId,OBJ_ID);
        }
        /// <summary>
        /// 判断文件是否已经共享到项目库中
        /// </summary>
        /// <param name="fileid"></param>
        /// <returns></returns>
        public bool hava_shared_xmk(string fileid)
        {
            Tb_Person_File_ShareData data = new Tb_Person_File_ShareData(Config.TadongDbProvider);
            return data.hava_shared_xmk(fileid);
        }
        /// <summary>
        /// 判断文件是否已经共享到课题组中
        /// </summary>
        /// <param name="fileid"></param>
        /// <returns></returns>
        public bool hava_shared_team(string fileid,string teamid)
        {
            Tb_Person_File_ShareData data = new Tb_Person_File_ShareData(Config.TadongDbProvider);
            return data.hava_shared_team(fileid, teamid);
        }
    }
}
